package com.iwhalecloud.bss.kite.cucc.service.attr;

import com.iwhalecloud.bss.kite.client.dto.DataResult;
import com.iwhalecloud.bss.kite.client.dto.inst.InstAttrDTO;
import com.iwhalecloud.bss.kite.common.constant.ErrorConsts;
import com.iwhalecloud.bss.kite.cucc.client.api.attr.ILocalQuerySceneOrderAttrService;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.service.util.CopyToDtoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Service
public class LocalQuerySceneOrderAttrService implements ILocalQuerySceneOrderAttrService {

	@Autowired
	private IQuerySceneInstService querySceneInstService;

	@Override
	public DataResult<List<InstAttrDTO>> listOrderAttrs(String sceneInstId, String objType) {
		List<KiteAttr> orderAttrs = querySceneInstService.listCommonAttrs(sceneInstId, objType);
		orderAttrs = Optional.ofNullable(orderAttrs).orElse(new ArrayList<>());
		return ErrorConsts.SUCCESS.getResult(CopyToDtoUtil.transInstAttrDtoList(orderAttrs));
	}

}
